﻿using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.EntityFrameworkCore;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MESMian.EntityMapping
{
    public class ProductionProcessesMapping : IEntityTypeConfiguration<ProductionProcesses>
    {
        public void Configure(EntityTypeBuilder<ProductionProcesses> builder)
        {
            builder.ToTable("ProductionProcesses");
            builder.HasKey(pp => pp.ProductionProcessId);
            builder.Property(pp => pp.ProductionProcessId)
                .HasComment("工序主键，自动编号");

            builder.Property(pp => pp.ProductionProcessCode)
                .IsRequired()
                .HasColumnType("varchar(20)")
                .HasComment("工序编号，不能重复");

            builder.Property(pp => pp.ProductionProcessName)
                .IsRequired()
                .HasColumnType("varchar(30)")
                .HasComment("工序名称，不能重复");

            builder.Property(pp => pp.ProcessRequirements)
                .IsRequired()
                .HasColumnType("varchar(200)")
                .HasComment("工序要求");

            builder.Property(pp => pp.ProcessDrawings)
                .HasColumnType("image")
                .HasComment("工序图纸");

            builder.Property(pp => pp.Remark)
                .HasColumnType("varchar(150)")
                .HasComment("备注");

            builder.Property(pp => pp.Status)
                .IsRequired()
                .HasColumnType("int")
                .HasDefaultValue(0)
                .HasComment("数据状态（0正常，1删除），默认值0");

            builder.Property(pp => pp.CreateUserId)
                .IsRequired()
                .HasColumnType("int")
                .HasComment("创建人，外键（Users）");

            builder.Property(pp => pp.CreateTime)
                .IsRequired()
                .HasColumnType("datetime")
                .HasDefaultValueSql("GETDATE()")
                .HasComment("创建时间，默认值为当前时间");

            builder.Property(pp => pp.LastUpdateUserId)
                .HasColumnType("int")
                .HasComment("最后一次修改人，外键（Users）");

            builder.Property(pp => pp.LastUpdateTime)
                .HasColumnType("datetime")
                .HasComment("最后一次修改时间");
        }
    }

}
